program main
    implicit none
    real(kind=8) :: a,b,c,delta
    complex(kind=8) :: x1,x2
    write(*,*) 'a:'
    read(*,*) a
    write(*,*) 'b:'
    read(*,*) b
    write(*,*) 'c:'
    read(*,*) c
    if (a == 0.0) then
        write(*,*) "'a' should not equal to zero!"
        stop
    end if
!    delta = b**2-4*a*c
!    if (delta >= 0.0) then
!        x1 = (-b+delta**0.5)/(2.0*a)
!        x2 = (-b-delta**0.5)/(2.0*a)
!    else
!        write(*,*) 'No real root.'
!        goto 1
!    end if
!    write(*,*) 'x1=',x1
!    write(*,*) 'x2=',x2
!1   write(*,*) 'End.'
    delta = b**2-4.0*a*c
    if (delta>=0.0)then
        x1 = cmplx( (-b+delta**0.5)/(2.0*a) )
        x2 = cmplx( (-b-delta**0.5)/(2.0*a) )
    else
        x1 = (-b+cmplx(delta)**0.5)/(2.0*a)
        x2 = (-b-cmplx(delta)**0.5)/(2.0*a)
    end if
    if (aimag(x1)<1D-9) then
        write(*,1) 'x1=',real(x1)
        write(*,1) 'x2=',real(x2)
    else
        write(*,1) 'x1=',real(x1),aimag(x1),'i'
        write(*,1) 'x2=',real(x2),aimag(x2),'i'
    end if
1   format(3x,A3,sp,f9.5,sp,f9.5,A1)
end program main
